/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "ALBUMTYPE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Albumtype.findAll", query = "SELECT a FROM Albumtype a"),
    @NamedQuery(name = "Albumtype.findByTypeId", query = "SELECT a FROM Albumtype a WHERE a.typeId = :typeId"),
    @NamedQuery(name = "Albumtype.findByTypeName", query = "SELECT a FROM Albumtype a WHERE a.typeName = :typeName"),
    @NamedQuery(name = "Albumtype.findByCreatedBy", query = "SELECT a FROM Albumtype a WHERE a.createdBy = :createdBy"),
    @NamedQuery(name = "Albumtype.findByCreatedDate", query = "SELECT a FROM Albumtype a WHERE a.createdDate = :createdDate"),
    @NamedQuery(name = "Albumtype.findByModifiedBy", query = "SELECT a FROM Albumtype a WHERE a.modifiedBy = :modifiedBy"),
    @NamedQuery(name = "Albumtype.findByModifiedDate", query = "SELECT a FROM Albumtype a WHERE a.modifiedDate = :modifiedDate")})
public class Albumtype implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "TYPE_ID")
    private Long typeId;
    @Basic(optional = false)
    @Column(name = "TYPE_NAME")
    private String typeName;
    @Basic(optional = false)
    @Column(name = "CREATED_BY")
    private String createdBy;
    @Basic(optional = false)
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;
    @Column(name = "MODIFIED_BY")
    private String modifiedBy;
    @Column(name = "MODIFIED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date modifiedDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "typeId")
    private List<Album> albumList;

    public Albumtype() {
    }

    public Albumtype(Long typeId) {
        this.typeId = typeId;
    }

    public Albumtype(Long typeId, String typeName, String createdBy, Date createdDate) {
        this.typeId = typeId;
        this.typeName = typeName;
        this.createdBy = createdBy;
        this.createdDate = createdDate;
    }

    public Long getTypeId() {
        return typeId;
    }

    public void setTypeId(Long typeId) {
        Long oldTypeId = this.typeId;
        this.typeId = typeId;
        changeSupport.firePropertyChange("typeId", oldTypeId, typeId);
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        String oldTypeName = this.typeName;
        this.typeName = typeName;
        changeSupport.firePropertyChange("typeName", oldTypeName, typeName);
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        String oldCreatedBy = this.createdBy;
        this.createdBy = createdBy;
        changeSupport.firePropertyChange("createdBy", oldCreatedBy, createdBy);
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        Date oldCreatedDate = this.createdDate;
        this.createdDate = createdDate;
        changeSupport.firePropertyChange("createdDate", oldCreatedDate, createdDate);
    }

    public String getModifiedBy() {
        return modifiedBy;
    }

    public void setModifiedBy(String modifiedBy) {
        String oldModifiedBy = this.modifiedBy;
        this.modifiedBy = modifiedBy;
        changeSupport.firePropertyChange("modifiedBy", oldModifiedBy, modifiedBy);
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        Date oldModifiedDate = this.modifiedDate;
        this.modifiedDate = modifiedDate;
        changeSupport.firePropertyChange("modifiedDate", oldModifiedDate, modifiedDate);
    }

    @XmlTransient
    public List<Album> getAlbumList() {
        return albumList;
    }

    public void setAlbumList(List<Album> albumList) {
        this.albumList = albumList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (typeId != null ? typeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Albumtype)) {
            return false;
        }
        Albumtype other = (Albumtype) object;
        if ((this.typeId == null && other.typeId != null) || (this.typeId != null && !this.typeId.equals(other.typeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.typeName;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
